package com.arithmetic.tree;

import cn.hutool.core.util.ArrayUtil;
import org.junit.jupiter.api.Test;

/**
 * @author chenyichang
 * @since 2022/8/15
 */
public class TreeNodeArithmeticTest {

    public static TreeNode root = null;

    static {
        root = new TreeNode(1);
        root.left = new TreeNode(9);
        root.left.left = new TreeNode(8);
        root.left.right = new TreeNode(4);
        root.left.left.left = new TreeNode(4);
        root.left.left.left.left = new TreeNode(9);
        root.left.left.left.left.right = new TreeNode(8);
        root.left.left.left.left.right.left = new TreeNode(4);
        root.left.left.left.left.right.right = new TreeNode(1);
        root.left.left.left.left.right.left.left = new TreeNode(3);
        root.left.left.left.left.right.left.right = new TreeNode(5);
        root.left.left.left.left.right.left.left.left = new TreeNode(2);

    }

    @Test
    public void levelOrderTest() {
        System.out.println(TreeNodeArithmetic.levelOrder(root));
    }

    @Test
    public void postorderTraversalTest() {
        int[] ints = TreeNodeArithmetic.postorderTraversal(root);
        System.out.println(ArrayUtil.toString(ints));
    }

    @Test
    public void inorderTraversalTest() {
        int[] ints = TreeNodeArithmetic.inorderTraversal(root);
        System.out.println(ArrayUtil.toString(ints));
    }

    @Test
    public void preOrderTraversalTest() {
        int[] ints = TreeNodeArithmetic.preorderTraversal(root);
        System.out.println(ArrayUtil.toString(ints));
    }
}
